package cn.edu.java.stream.泛型;

import java.util.ArrayList;
import java.util.List;

public class WildcardDemo {

    public static <T extends Number> void printList(List<T> list) {  // public static void printList(List<? extends Number> list)
        for (Object element : list) {
            System.out.println(element);
        }
    }

    public static void main(String[] args) {
        List<Integer> integerList = new ArrayList<>();
        integerList.add(1);
        integerList.add(2);
        integerList.add(3);

        List<Double> doubleList = new ArrayList<>();
        doubleList.add(1.1);
        doubleList.add(2.2);
        doubleList.add(3.3);

        printList(integerList);
        printList(doubleList);
    }

}
